package com.zhiyou100.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhiyou100.mapper.UserMapper;
import com.zhiyou100.model.User;
import com.zhiyou100.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;

	@Override
	public User selectUserById(Integer id) {
		// TODO Auto-generated method stub
		return userMapper.selectUserById(id);
	}

	@Override
	public int deleteById(Integer id) {
		
		return userMapper.deleteById(id);
	}

	@Override
	public int updateUser(User user) {
		// TODO Auto-generated method stub
		return userMapper.updateUser(user);
	}

	@Override
	public int insertUser(String email,String password) {
		// TODO Auto-generated method stub
		User user = new User();
		user.setEmail(email);
		user.setPassword(password);
		return userMapper.insertUser(user);
	}

	@Override
	public User selectUserByEmail(String email) {
		
		return userMapper.selectUserByEmail(email);
	}

	@Override
	public List<User> selectAll() {
		// TODO Auto-generated method stub
		return userMapper.selectAll();
	}

	@Override
	public User checkUser(String email, String password) {
		// TODO Auto-generated method stub
		User user = new User();
		user.setEmail(email);
		user.setPassword(password);
		return userMapper.checkUser(user);
	}

	@Override
	public int updateUserPassword(String email,String password) {
		// TODO Auto-generated method stub
		User user = new User();
		user.setEmail(email);
		user.setPassword(password);
		return userMapper.updateUserPassword(user);
	}


	
}
